/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "pedido_cliente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PedidoCliente.findAll", query = "SELECT p FROM PedidoCliente p"),
    @NamedQuery(name = "PedidoCliente.findByCodPedCli", query = "SELECT p FROM PedidoCliente p WHERE p.codPedCli = :codPedCli"),
    @NamedQuery(name = "PedidoCliente.findByFecha", query = "SELECT p FROM PedidoCliente p WHERE p.fecha = :fecha"),
    @NamedQuery(name = "PedidoCliente.findByTotal", query = "SELECT p FROM PedidoCliente p WHERE p.total = :total"),
    @NamedQuery(name = "PedidoCliente.findByDescuento", query = "SELECT p FROM PedidoCliente p WHERE p.descuento = :descuento"),
    @NamedQuery(name = "PedidoCliente.findByFPago", query = "SELECT p FROM PedidoCliente p WHERE p.fPago = :fPago")})
public class PedidoCliente implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_ped_cli")
    private Integer codPedCli;
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "total")
    private double total;
    @Lob
    @Column(name = "observaciones")
    private String observaciones;
    @Basic(optional = false)
    @Column(name = "descuento")
    private int descuento;
    @Column(name = "f_pago")
    private String fPago;
    @JoinColumn(name = "cod_trab", referencedColumnName = "cod_trab")
    @ManyToOne(optional = false)
    private Trabajadores codTrab;
    @JoinColumn(name = "dni", referencedColumnName = "dni")
    @ManyToOne(optional = false)
    private Cliente dni;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pedidoCliente", fetch=FetchType.EAGER)
    private List<DetallePedCli> detallePedCliList;

    public PedidoCliente() {
    }

    public PedidoCliente(Integer codPedCli) {
        this.codPedCli = codPedCli;
    }

    public PedidoCliente(Integer codPedCli, double total, int descuento) {
        this.codPedCli = codPedCli;
        this.total = total;
        this.descuento = descuento;
    }

    public Integer getCodPedCli() {
        return codPedCli;
    }

    public void setCodPedCli(Integer codPedCli) {
        this.codPedCli = codPedCli;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public double getTotal() {
        return total;
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        this.observaciones = observaciones;
    }

    public int getDescuento() {
        return descuento;
    }

    public void setDescuento(int descuento) {
        this.descuento = descuento;
    }

    public String getFPago() {
        return fPago;
    }

    public void setFPago(String fPago) {
        this.fPago = fPago;
    }

    public Trabajadores getCodTrab() {
        return codTrab;
    }

    public void setCodTrab(Trabajadores codTrab) {
        this.codTrab = codTrab;
    }

    public Cliente getDni() {
        return dni;
    }

    public void setDni(Cliente dni) {
        this.dni = dni;
    }

    @XmlTransient
    public List<DetallePedCli> getDetallePedCliList() {
        return detallePedCliList;
    }

    public void setDetallePedCliList(List<DetallePedCli> detallePedCliList) {
        this.detallePedCliList = detallePedCliList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codPedCli != null ? codPedCli.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PedidoCliente)) {
            return false;
        }
        PedidoCliente other = (PedidoCliente) object;
        if ((this.codPedCli == null && other.codPedCli != null) || (this.codPedCli != null && !this.codPedCli.equals(other.codPedCli))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hibernate.entidades.PedidoCliente[ codPedCli=" + codPedCli + " ]";
    }
    
}
